home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC02BusyBox / BusyBox.c / UMenu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-25  |  2.3 KB  |  95 lines  |  [04] ASCII Text (0x0000)

  1. /***********************************************************************
  2. *
  3. * busybox umenu.c -- Version 3.0 
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements 
  12. * menus in the busybox program.
  13. *
  14. ***********************************************************************/
  15.  
  16. #include <types.h>
  17. #include <quickdraw.h>
  18. #include <window.h>
  19. #include <event.h>
  20. #include <menu.h>
  21. #include <desk.h>
  22. #include <intmath.h>
  23.  
  24. #include "busybox.h"
  25.  
  26. extern WmTaskRec        event;
  27. extern unsigned int     quitFlag;
  28.  
  29. /**********************************************************************/
  30.  
  31. void    doQuitItem()
  32. {
  33.     quitFlag++;
  34. }
  35.  
  36. /**********************************************************************/
  37.  
  38. void    doAboutItem()
  39. {
  40.     AlertWindow(4, NULL, 0x0001L);
  41. }
  42.  
  43. /**********************************************************************/
  44.  
  45. void    doMenu()
  46. {
  47.     unsigned int    menuNum, itemNum;
  48.  
  49.     /* Procedure to handle all menu selections.  Examines the event.TaskData
  50.     ** menu item ID word from TaskMaster (from Event Manager) and calls the
  51.     ** appropriate routine.  While the routine is running the menu title is
  52.     ** still highlighted.  After the routine returns, we unhilight the
  53.     ** menu title.
  54.     */
  55.  
  56.     menuNum = HiWord(event.wmTaskData);
  57.     itemNum = LoWord(event.wmTaskData);
  58.  
  59.     switch (itemNum) {
  60.         case AboutItem:
  61.             doAboutItem();
  62.             break;
  63.         case CloseItem:
  64.             doCloseTop();
  65.             break;
  66.         case QuitItem:
  67.             doQuitItem();
  68.             break;
  69.         case UndoItem:
  70.         case CutItem:
  71.         case CopyItem:
  72.         case PasteItem:
  73.         case ClearItem:
  74.             break;
  75.     }
  76.  
  77.     HiliteMenu(0, menuNum);     /* Unhighlight the menu title. */
  78. }
  79.  
  80. /**********************************************************************/
  81.  
  82. void    setupMenus()
  83. {
  84.     /* Procedure to install our menu titles and their items in the system menu
  85.     ** bar and to redraw it so we can see them.
  86.     */
  87.  
  88.     SetSysBar(NewMenuBar2(refIsResource, 0x1000L, NULL));
  89.     SetMenuBar(NULL);
  90.     
  91.     FixAppleMenu(AppleMenuID);              /* Add DAs to apple menu     */
  92.     FixMenuBar();                           /* Set sizes of menus        */
  93.     DrawMenuBar();                          /* ...and draw the menu bar! */
  94. }
  95.